package PL.prac3;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import org.antlr.runtime.ANTLRFileStream;
import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws RecognitionException 
	 */
	public static void main(String[] args) throws IOException, RecognitionException {
		if (args.length != 0) {
			ANTLRFileStream ent = new ANTLRFileStream(args[0]);
			Analex analex =new Analex(ent);
			CommonTokenStream tokens = new CommonTokenStream(analex);
			Anasin anasin = new Anasin(tokens);
			anasin.entrada_fichero();
		}
		else {
			System.out.println("Introduzca código: ");
			String linea = "a";
			String parada = "$";
			BufferedReader bf = new BufferedReader (new InputStreamReader(System.in)); 
			while (!linea.equals(parada)) {
				linea = bf.readLine();
				ANTLRStringStream ent = new ANTLRStringStream(linea);
				Analex a =new Analex(ent);
				CommonTokenStream tokens = new CommonTokenStream(a);
				Anasin anasin = new Anasin(tokens);
				anasin.entrada_sin ();
			}
		}		
	}
}

